package com.takeaway.controller;


import com.takeaway.pojo.ProductCetegory;
import com.takeaway.pojo.ResultVO;
import com.takeaway.service.ProductCategoryService;
import com.takeaway.utils.ResultVOUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @ClassName:com.takeaway.controller
 * @TODO:
 * @Author:Robbie
 * @Date:2021/7/30 20:01
 * @Version：0.0.1
 **/


@RestController
@RequestMapping("/meishipai/product-category")
@Api(value = "商品类目", tags = "商品类目展示&管理")

public class ProductCategoryController {

    @Autowired
    ProductCategoryService productCategoryService;
    @Autowired
    ProductCetegory productCetegory;


    /**
     * @param pageNum:
     * @param limit:
     * @Description:
     * @Author: Robbie
     * @Date: 2021/7/30 20:12
     * @return: com.takeaway.pojo.ResultVO<java.lang.String>
     * @other： eg : product-category/list?page=1&limit=10
     * 注意：layUI中目前page:true 分页交给layUI处理
     **/

    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ApiOperation(value = "获取当前商品的类目列表")
    public ResultVO<String> showProductCategoryList(@ApiParam("显示页码") String pageNum, @ApiParam("分页数目") String limit) {
        System.out.println("开始查询商品类目详情");
        List<ProductCetegory> productCetegoryList = productCategoryService.showProductCategoryList();
        return ResultVOUtil.success();
    }



    @RequestMapping(value = "/addCategory",method = RequestMethod.POST)
    @ApiOperation(value = "新增商品类目")
    public ResultVO<String> addCategory(ProductCetegory productCetegory){
     int count =   productCategoryService.addCategory(productCetegory);
     if (count>0){
         return  ResultVOUtil.success("新增成功");
     }else {
         return ResultVOUtil.error(1,"新增失败");
     }
    }


}



